package 寒假作业.LeetCode;

public class Num206 {
      public class ListNode {
      int val;
      ListNode next;
      ListNode() {}
      ListNode(int val) { this.val = val; }
      ListNode(int val, ListNode next) { this.val = val; this.next = next; }
  }
    public ListNode reverseList(ListNode head) {
          if(head == null || head.next == null){
              return head;
          }
          //一个一个递出去
          ListNode tmpHead = head.next;
          ListNode newHead = reverseList(head.next);
          //一个一个返回来
          tmpHead.next = head;
          head.next = null;
          return newHead;
    }
}
